Ext.onReady(function(){
    Ext.define('json_data',{
        extend: 'Ext.data.Model',
        fields: [
			 {name:'id',type:'string'},
			 {name:'company__cn_name',type:'string'},
             {name:'name',type:'string'},
             {name:'gender',type:'string'},
             {name:'employed_data',type:'y年m月d日'},
             {name:'positive_data',type:'y年m月d日'},
             {name:'identity_card',type:'string'},
             {name:'registered_residence',type:'string'},
             {name:'birthday',type:'string'},
             {name:'phone',type:'string'},
             {name:'email',type:'string'},
             {name:'qq',type:'string'},
             {name:'education',type:'string'},
             {name:'profession',type:'string'},
             {name:'graduate_school',type:'string'},
             {name:'work_experience',type:'string'},
             {name:'state',type:'string'},
             {name:'leave_date',type:'y年m月d日'},
             {name:'company_id',type:'string'},
             {name:'company__cn_name',type:'string'},
             {name:'department_id',type:'string'},
             {name:'department__name',type:'string'},
             {name:'office_id',type:'string'},
             {name:'office__name',type:'string'},
             {name:'salary_grade',type:'string'},
             {name:'position_level',type:'string'},
             {name:'course_desc',type:'string'}
        ]
    });
    //创建数据源
    var store = Ext.create('Ext.data.Store', {
    	pageSize:20,
        model: 'json_data',
	    proxy: {
	        type: 'ajax',
	        url: '/employecontrol/employe_list/',
	        actionMethods:'post',
	        reader: {
	            type: 'json',
	            root: 'rows',
	            totalProperty: 'totalCount'
	        }
	    },
	    autoLoad: false
    });
    
    //校区combox
    var companyComboboxForm= Ext.create('Ext.form.field.ComboBox', {
        id:'company_id',
	   	name:'company_id',
       	fieldLabel: '校区', 
       	allowBlank : false,
       	editable:false,
       	emptyText: '请选择',
       	store: new Ext.data.Store({ 
           	singleton : true, 
	   	    proxy: {
	   	        type: 'ajax',
	   	        url: '/resourcecontrol/company_select_all/',
	   	        actionMethods:'post',
	   	        reader: {
	   	            type: 'json'
	   	        }
	   	    },
           fields:['id', 'cn_name'], 
           autoLoad:true 
       	}), 
       	loadingText:'正在加载数据，请稍侯……', 
       	triggerAction:'all', 
       	valueField:'id', 
       	displayField:'cn_name'
    });
    
    //部门combox
    var departmentComboBox= Ext.create('Ext.form.field.ComboBox', { 
       id:'department_id',
	   name:'department_id',
	   allowBlank : false,
       fieldLabel: '部门', 
       editable:false,
       store: new Ext.data.Store({ 
           singleton : true, 
	   	   proxy: {
	   	        type: 'ajax',
	   	        url: '/resourcecontrol/department_select/',
	   	        actionMethods:'post',
	   	        reader: {
	   	            type: 'json'
	   	        }
	   	    },
           fields:['id', 'name'],
           autoLoad:true 
       }), 
       loadingText:'正在加载数据，请稍侯……', 
       triggerAction:'all', 
       valueField:'id', 
       displayField:'name'
    });
    
    //职务combox
    var officeComboBox= Ext.create('Ext.form.field.ComboBox', { 
    	id:'office_id',
    	name:'office_id',
    	allowBlank : false,
    	fieldLabel: '职务', 
    	editable:false,
    	store: new Ext.data.Store({ 
    		singleton : true, 
    		proxy: {
    		type: 'ajax',
    		url: '/resourcecontrol/office_select/',
    		actionMethods:'post',
    		reader: {
    		type: 'json'
    	}
    	},
    	fields:['id', 'name'],
    	autoLoad:true 
    	}), 
    	loadingText:'正在加载数据，请稍侯……', 
    	triggerAction:'all', 
    	valueField:'id', 
    	displayField:'name'
    }); 
    var data123=[
		{'id':'1','value':'一级'},
		{'id':'2','value':'二级'},
		{'id':'3','value':'三级'},
		{'id':'4','value':'四级'},
		{'id':'5','value':'五级'}
	]
    var data3=[
		{'id':'1','value':'一级'},
		{'id':'2','value':'二级'},
		{'id':'3','value':'三级'},
		{'id':'4','value':'四级'},
		{'id':'5','value':'五级'},
		{'id':'6','value':'六级'}
	]
	var data4=[
		{'id':'1','value':'一级'},
		{'id':'2','value':'二级'},
		{'id':'3','value':'三级'},
		{'id':'4','value':'四级'},
		{'id':'5','value':'五级'},
		{'id':'6','value':'六级'},
		{'id':'7','value':'七级'},
		{'id':'8','value':'八级'},
		{'id':'9','value':'九级'},
		{'id':'10','value':'十级'},
		{'id':'11','value':'十一级'},
		{'id':'12','value':'十二级'},
		{'id':'13','value':'十三级'},
		{'id':'14','value':'十四级'},
		{'id':'15','value':'十五级'}
	]
	
	// 兼职
	var data5=[
		{'id':'1','value':'一级'},
		{'id':'2','value':'二级'},
		{'id':'3','value':'三级'},
		{'id':'4','value':'四级'},
		{'id':'5','value':'五级'},
		{'id':'6','value':'六级'},
		{'id':'7','value':'七级'},
		{'id':'8','value':'八级'},
		{'id':'9','value':'九级'},
		{'id':'10','value':'十级'},
		{'id':'11','value':'十一级'},
		{'id':'12','value':'十二级'},
		{'id':'13','value':'十三级'},
		{'id':'14','value':'十四级'},
		{'id':'15','value':'十五级'},
		{'id':'16','value':'十六级'},
		{'id':'17','value':'十七级'},
		{'id':'18','value':'十八级'},
		{'id':'19','value':'十九级'},
		{'id':'20','value':'二十级'},
		{'id':'21','value':'二十一级'},
		{'id':'22','value':'二十二级'}
	]
    var levelComboBox= Ext.create('Ext.form.field.ComboBox', {
			xtype:'combobox',
			editable:false,
			queryMode: 'local',
			valueField:'id',
			displayField:'value',
			fieldLabel : '等级',
			name : 'position_level',
			id : 'position_level',
			allowBlank : true,
			blankText : '请输入',
			store: Ext.create('Ext.data.Store',{
				autoLoad:true,
				fields:['id','value'], 
				data: data5
			}),
			columnWidth: 1/2
		});
		
    var gradeComboBox= Ext.create('Ext.form.field.ComboBox',{
			xtype:'combobox',
			editable:false,
			valueField:'id',
			displayField:'value',
			queryMode:'local',
			fieldLabel : '薪档',
			name : 'salary_grade',
			id : 'salary_grade',
			allowBlank : true,
			blankText : '请输入',
			store:Ext.create('Ext.data.Store',{
				fields:['id','value'], 
				data:[
					{'id':'1','value':'XD(A)'},
					{'id':'2','value':'XD(B)'},
					{'id':'3','value':'XD(C)'},
					{'id':'4','value':'XD(D)'},
					{'id':'5','value':'JZXD(E)'}
				]
			}),
			columnWidth: 1/2,
			listeners: {
        		'select': function(combo, records, opts) {	
        			if( gradeComboBox.getValue()=='4' ){
        				levelComboBox.getStore().loadData(data4);
        			}else if(gradeComboBox.getValue()=='3'){
        				levelComboBox.getStore().loadData(data3);
        			}else if(gradeComboBox.getValue()=='5'){
        				levelComboBox.getStore().loadData(data5);
        			}else{
        				levelComboBox.getStore().loadData(data123);
        			}
        		}
        	}
	
		} );
    //多选
    var selModel = Ext.create('Ext.selection.CheckboxModel');
    //创建Grid
    var grid = Ext.create('Ext.grid.Panel',{
        store: store,
        //height: 500,
        //selModel:selModel,
        columnLines:true,
        columns: [
            Ext.create('Ext.grid.RowNumberer'),// 序列
			{text: "ID", width: 80, dataIndex: 'id', sortable: false,hidden : true},
            {text: "校区", width: 80, dataIndex: 'company__cn_name', sortable: false},
            {text: "姓名", width: 80, dataIndex: 'name', sortable: false},
            {text: "性别", width: 40, dataIndex: 'gender', sortable: false,
                renderer:function(v){
            	if (v==1) 
                	return '男'
    			else
        			return '女'
            	}
            },
            {text: "入职时间", width: 80, dataIndex: 'employed_data', sortable: false},
            {text: "转正时间", width: 80, dataIndex: 'positive_data', sortable: false},
            {text: "离职时间", width: 80, dataIndex: 'leave_date', sortable: false},
            {text: "身份证", width: 160, dataIndex: 'identity_card', sortable: false,hidden : true},
            {text: "户籍所在地", width: 70, dataIndex: 'registered_residence', sortable: false},
            {text: "生日", width: 120, dataIndex: 'birthday', sortable: false},
            {text: "手机", width: 120, dataIndex: 'phone', sortable: false},
            {text: "邮箱", width: 120, dataIndex: 'email', sortable: false,hidden : true},
            {text: "QQ", width: 120, dataIndex: 'qq', sortable: false},
            {text: "学历", width: 120, dataIndex: 'education', sortable: false},
            {text: "专业", width: 120, dataIndex: 'profession', sortable: false},
            {text: "毕业学校", width: 120, dataIndex: 'graduate_school', sortable: false},
            {text: "从业经历", width: 120, dataIndex: 'work_experience', sortable: false},
            {text: "状态", width: 120, dataIndex: 'state', sortable: false,
                renderer:function(v){
            	if (v==1) 
                	return '入职试用期'
            	if (v==2) 
            		return '转正'
        		if (v==3) 
        			return '离职'
    			if (v==4) 
    				return '全职'
				if (v==5) 
					return '兼职'
    			else
        			return '招聘'
            	}},
            {text: "校区ID", width: 120, dataIndex: 'company_id', sortable: false,hidden : true},
            {text: "校区", width: 120, dataIndex: 'company__cn_name', sortable: false},
            {text: "部门ID", width: 120, dataIndex: 'department_id', sortable: false,hidden : true},
            {text: "部门", width: 120, dataIndex: 'department__name', sortable: false},
            {text: "职务ID", width: 120, dataIndex: 'office_id', sortable: false,hidden : true},
            {text: "职务", width: 120, dataIndex: 'office__name', sortable: false},
            {text: "课程说明", width: 120, dataIndex: 'course_desc', sortable: false},
            {text: "薪档", width: 120, dataIndex: 'salary_grade', sortable: false,
                renderer:function(v){
            	if (v==1) 
                	return 'XD(A)'
            	if (v==2) 
            		return 'XD(B)'
        		if (v==3) 
        			return 'XD(C)'
    			if (v==4) 
    				return 'XD(D)'
            	}},
            {text: "级别", width: 120, dataIndex: 'position_level', sortable: false,
                renderer:function(v){
                	if (v==1) 
	                	return '一级' ;
	            	if (v==2) 
	            		return '二级' ;
	        		if (v==3) 
	        			return '三级' ;
	    			if (v==4) 
	    				return '四级' ;
					if (v==5) 
						return '五级' ;
					if (v==6) 
						return '六级' ;
					if (v==7) 
						return '七级' ;
					if (v==8)
						return '八级' ;
					if (v==9) 
						return '九级' ;
					if (v==10) 
						return '十级' ;
					if (v==11) 
						return '十一级' ;
					if (v==12) 
						return '十二级' ;
					if (v==13) 
						return '十三级' ;
					if (v==14) 
						return '十四级' ;
					if (v==15) 
						return '十五级' ;
					if (v==16) 
						return '十六级' ;
					if (v==17) 
						return '十七级' ;
					if (v==18) 
						return '十八级' ;
					if (v==19) 
						return '十九级' ;
					if (v==20) 
						return '二十级' ;
					if (v==21) 
						return '二十一级' ;
					if (v==22) 
						return '二十二级' ;
    				
                }}
        ],
        //title: '员工信息管理',
        // disableSelection: false,
        layout : 'fit',
        //frame:true, 取消边框
        loadMask:true,
        region: 'north',
        //renderTo: 'employee-grid',
        viewConfig: {
            stripeRows: true,
            listeners: {
                itemclick: function(dataview, record, item, index, e) {
    				
                },
                itemdblclick: function(dataview, record, item, index, e) {
                	form.getForm().reset();
        			var selected = grid.getSelectionModel().getSelection();
					form.loadRecord(selected[0]);
					queryAttachment();
        			win.show();
                }
            }
        },
        dockedItems : [{
            xtype : 'pagingtoolbar',
            store : store,
            dock : 'bottom',
            displayInfo : true,
            //displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
            autoScroll:true 
        },{
        	dock:'top',
        	xtype:'toolbar',
        	items:[{
        		xtype: 'combobox',
        		id:'company_combox_id',
            	name:'company',
            	labelWidth: 40,
            	width: 140,
               	fieldLabel: '校区',
               	emptyText: '请选择校区',
               	editable:false,
               	store: new Ext.data.Store({ 
                   	singleton : true, 
        	   	    proxy: {
        	   	        type: 'ajax',
        	   	        url: '/resourcecontrol/company_select_all/',
        	   	        actionMethods:'post',
        	   	        reader: {
        	   	            type: 'json'
        	   	        }
        	   	    },
                   fields:['id', 'cn_name'], 
                   autoLoad:true 
               	}), 
               	loadingText:'正在加载数据，请稍侯……', 
               	triggerAction:'all', 
               	valueField:'id', 
               	displayField:'cn_name'        		
        	},{
				xtype:'combobox',
				id:'state',
            	name:'state',
            	labelWidth: 40,
            	width: 160,
				editable:false,
				valueField:'id',
				displayField:'value',
				queryMode:'local',
				fieldLabel : '状态',
				allowBlank : true,
				emptyText : '请选择员工状态',
				store:Ext.create('Ext.data.Store',{
					fields:['id','value'], 
					data:[
                        {'id':'','value':'全部'},
						{'id':'1','value':'入职试用期'},
						{'id':'2','value':'转正'},
						{'id':'3','value':'离职'},
						//{'id':'4','value':'全职'},
						{'id':'5','value':'兼职'},
						{'id':'6','value':'招聘'}
					]
				})
			},{
        		id:'name',
        		xtype:'textfield',
        		labelWidth: 30,
        		width : 120,
        		fieldLabel:'姓名'
        	},{
        		id:'course_desc',
        		xtype:'textfield',
        		labelWidth: 60,
        		width : 150,
        		fieldLabel:'课程说明'
        	},{
        		xtype:'button',
        		text:'查询',
        		iconCls:'search', 
        		handler:function(){
	        		if(Ext.getCmp('company_combox_id').getValue()!=null){
	        			//var params = { company_id:Ext.getCmp('company_combox_id').getValue() ,name: Ext.getCmp('name').getValue() };
	        			//if(Ext.getCmp('state').getValue()!=null){
	        				params = {company_id:Ext.getCmp('company_combox_id').getValue() ,
	        						  name: Ext.getCmp('name').getValue(),
	        						  course_desc: Ext.getCmp('course_desc').getValue(),
	        						  state:Ext.getCmp('state').getValue() };
	        			//}
	        		    Ext.apply(store.proxy.extraParams, params);
	        		    store.currentPage=1;
	        		    store.load();
	    			}else{
	    				Ext.Msg.alert('系统提示', '请选择校区!');
	    			}
        		}
        	},{
        		xtype:'button',
        		text:'添加',
        		iconCls:'add', 
        		handler:function(){
        			form.getForm().reset();
        			win.show();
        		}
        	},{
        		xtype:'button',
        		text:'修改',
        		iconCls:'edit', 
        		handler:function(){
        			var selected = grid.getSelectionModel().getSelection();
	    			if(selected!=''){
	    				form.getForm().reset();
						form.loadRecord(selected[0]);
						queryAttachment();
	        			win.show();
	    			}else{
	    				Ext.Msg.alert('系统提示', '请选择需要修改的员工!');
	    			}
        		}
        	},{
        		xtype:'button',
        		text:'删除',
        		iconCls:'delete', 
        		handler:function(){
        			var selected = grid.getSelectionModel().getSelection();
	    			if(selected!=''){
	    				Ext.MessageBox.confirm('提示', '确认删除吗?', function(btn){
	        				if(btn=='yes'){
	        					var ids="";
	                			Ext.each(selected, function (item) {
	                				ids+=item.data.id+",";
	                			});
	                			Ext.Ajax.request({
	                			    url:'/employecontrol/employe_del/',
	                			    method : 'post',
	                			    params:{
	                			    	ids:ids
	                			    },
	                			    success:function(response){
	                			        var results =  Ext.decode(response.responseText);
	                			        if(results.success){
	                			        	store.load();
	                			        }else{
	                			        	Ext.Msg.alert('系统提示', results.message);
	                			        }
	                			    }
	                			});
	        				}
	        			});
	    			}else{
	    				Ext.Msg.alert('系统提示', '请选择需要删除的员工!');
	    			}
        			
        		}
        	}
//        	,{
//        		xtype:'button',
//        		text:'附件上传',
//        		handler:function(){
//        			Ext.Msg.alert('系统提示', '此功能正在研发中...');
//        		}
//        	}
        	]
        }]
    });
    
	function queryAttachment(){
		Ext.getCmp('attachmentContainer').removeAll();
		var selected = grid.getSelectionModel().getSelection();
		Ext.Ajax.request({
		    url:'/employecontrol/employe_attachment_query/',
		    method : 'post',
		    params:{
		    	employeId:selected[0].data.id//附件ID
		    },
		    success:function(response){
		        var results =  Ext.decode(response.responseText);
		        if(results.success){
		        	for(var i=0;i<results.data.length;i++){
	            		var ChildContainer=Ext.create('Ext.container.Container',{
	            			id:results.data[i].path,
	            			name:results.data[i].name,
				            items: [{
			                    xtype: 'label',
			                    text: results.data[i].name
			                },{
			                    xtype: 'button',
			                    text: '下载',
			                    handler:function(){
			                    	window.open('/downloaded/?path='+this.findParentByType('container').id+'&name='+this.findParentByType('container').name);
			                    }
			            	}]		            			
	            		});	
	            		Ext.getCmp('attachmentContainer').add(ChildContainer);
		        	}
		        }else{
		        	Ext.Msg.alert('系统提示', results.message);
		        }
		    }
		});		
	}
    
    
	var form = Ext.create('Ext.form.Panel', {
		width: 550,
		//frame: true,
		bodyPadding: 5,
        fieldDefaults: {
            labelAlign: 'right',
            labelWidth: 90,
            msgTarget: 'side'
        },
        layout: 'anchor',
        defaults: {
            anchor: '100%'
        },
		items : [{
				xtype:'hiddenfield',
				fieldLabel:'id',
				name:'id'
			},{
			xtype:'container',
			layout:'hbox',
			defaultType:'textfield',
			items:[ {
				fieldLabel : '姓名',
				name : 'name',
				allowBlank : false,
				blankText : '请输入姓名'
			}, {
				xtype:'combobox',
				editable:false,
				valueField:'id',
				displayField:'value',
				queryMode:'local',
				fieldLabel : '性别',
				name : 'gender',
				allowBlank : false,
				blankText : '请输入性别',
				store:Ext.create('Ext.data.Store',{
					fields:['id','value'], 
					data:[
						{'id':'1','value':'男'},
						{'id':'2','value':'女'}
					]
				}),
				columnWidth: 1/2
			}]
		},{
			xtype:'container',
			layout:'hbox',
			defaultType:'datefield',
			items:[ {
				fieldLabel : '入职时间',
				editable:false,
				name : 'employed_data',
				allowBlank : false,
				format: 'Y-m-d',
				blankText : '请输入入职时间'
			}, {
				fieldLabel : '转正时间',
				editable:false,
				format: 'Y-m-d',
				name : 'positive_data',
				allowBlank : true
			}]
		},{
			xtype:'container',
			layout:'hbox',
			defaultType:'textfield',
			items:[ {
				fieldLabel : '身份证',
				name : 'identity_card',
				allowBlank : false,
				blankText : '请输入身份证'
			}, {
				fieldLabel : '户籍地址',
				name : 'registered_residence',
				allowBlank : true
			}]
		},{
			xtype:'container',
			layout:'hbox',
			defaultType:'datefield',
			items:[ {
				fieldLabel : '出生日期',
				name : 'birthday',
				editable:false,
				allowBlank : false,
				format: 'Y-m-d',
				blankText : '请输入出生日期'
			}, {
				xtype:'textfield',
				fieldLabel : '手机号码',
				name : 'phone',
				allowBlank : false
			}]
		},{
			xtype:'container',
			layout:'hbox',
			defaultType:'textfield',
			items:[ {
				fieldLabel : '邮箱地址',
				name : 'email',
				allowBlank : true,
				blankText : '请输入'
			}, {
				fieldLabel : 'QQ号码',
				name : 'qq',
				allowBlank : true
			}]
		},{
			xtype:'container',
			layout:'hbox',
			defaultType:'textfield',
			items:[ {
				fieldLabel : '学历',
				name : 'education',
				allowBlank : true,
				blankText : '请输入学历'
			}, {
				fieldLabel : '专业',
				name : 'profession',
				allowBlank : true
			}]
		},{
			xtype:'container',
			layout:'hbox',
			defaultType:'textfield',
			items:[ departmentComboBox,officeComboBox ]
		},{
			xtype:'container',
			layout:'hbox',
			//defaultType:'textfield',
			items:[ companyComboboxForm,{
				xtype:'combobox',
				editable:false,
				valueField:'id',
				displayField:'value',
				queryMode:'local',
				fieldLabel : '状态',
				name : 'state',
				allowBlank : false,
				blankText : '请输入',
				store:Ext.create('Ext.data.Store',{
					fields:['id','value'], 
					data:[
						{'id':'1','value':'入职试用期'},
						{'id':'2','value':'转正'},
						{'id':'3','value':'离职'},
						//{'id':'4','value':'全职'},
						{'id':'5','value':'兼职'},
						{'id':'6','value':'招聘'}
					]
				}),
				columnWidth: 1/2
			} ]
		},{
			xtype:'container',
			layout:'hbox',
			defaultType:'textfield',
			items:[ {
				xtype:'textfield',
				allowBlank : true,
				fieldLabel:'毕业学校',
				name:'graduate_school'
			}, {
				xtype:'datefield',
				fieldLabel:'离职时间',
				name:'leave_date',
				editable:false,
				allowBlank : true,
				format: 'Y-m-d',
				blankText : '请输入离职时间'
			}]
		},{
			xtype:'container',
			layout:'hbox',
			//defaultType:'textfield',
			items:[ gradeComboBox,levelComboBox ]
		},{
			xtype:'textfield',
			fieldLabel:'课程说明',
			name:'course_desc'
		},{
			xtype:'textareafield',
			fieldLabel:'从业经历',
			name:'work_experience'
		},{
            xtype: 'fieldcontainer',
            id:'attachmentContainer',
            height: 60,
            autoScroll: true,
            layout: {
                type: 'anchor'
            },
            anchor: '100%',
            fieldLabel: '附件'
        },{
			xtype:'hiddenfield',
			fieldLabel:'attachments',
			name:'attachments'
		},{
        	xtype:'filefield',
        	buttonText:'上传',
        	buttonOnly: true,
        	name:'file',
            listeners:{
            	change:function(me,value,eOpts){
            		var hasChild=Ext.getCmp('attachmentContainer').getChildByElement(value);
            		if(hasChild){
            			Ext.Msg.alert('系统提示', '附件已上传!');
            			return ;
            		}

            		fileForm=Ext.create('Ext.form.Panel');
            		fileForm.add(me);
					fileForm.getForm().submit({
						submitEmptyText:false,
						waitTitle : '请稍候',
						waitMsg : '正在处理......',
						url : '/uploaded/',
						success : function(form, action) {
							if (action.result) {
								Ext.Msg.alert('系统提示', action.result.message);
								
			            		var ChildContainer=Ext.create('Ext.container.Container',{
			            			id:value,
			            			name:action.result.filename,
						            items: [{
					                    xtype: 'label',
					                    text: value
					                },{
					                    xtype: 'button',
					                    text: '删除',
					                    handler:function(){
					                    	Ext.getCmp('attachmentContainer').remove(value);
					                    }
					            	}]		            			
			            		});
								Ext.getCmp('attachmentContainer').add(ChildContainer);	
							} 
						},
						failure : function(form, action) {
							if (action.result) {
								Ext.Msg.alert('系统提示', action.result.message);
							} 
						}
					});
            	}
            }                	
        }]
	});

	var win = Ext.create('Ext.window.Window', {
		//title : '---',
		modal: true,
		closeAction: 'hide',
		items : [form],
		plain : true,
		resizable : false,
		buttonAlign : 'center',
		buttons : [ {
			text : '保存',
			handler : function() {
				if (form.getForm().isValid()) {
					form.getForm().submit({
						//submitEmptyText:false,
						waitTitle : '请稍候',
						waitMsg : '正在处理......',
						url : '/employecontrol/employe_save/',
						success : function(form, action) {
							//Ext.Msg.alert('系统提示',  action.result.message);
							//form.getForm().reset();
							win.hide();
							store.load();
						},
						failure : function(form, action) {
							if (action.result) {
								Ext.Msg.alert('系统提示', action.result.message);
							} 
						}
					});
				}
			}
		}, {
			text : '取消',
			handler : function() {
				form.getForm().reset();
				win.hide();
			}
		}]
	});    
    
	// 适应屏幕
	Ext.create('Ext.container.Viewport',{
		layout:'fit',
		renderTo: 'employee-grid',
		items:[grid]
	});
	
});